package user_service

import (
	"muziai-server/global"
	"muziai-server/models"
	"muziai-server/models/ctype"
)

func (UserService) HasBindAccount(rs ctype.RegisterSource, val string) (ok bool, msg string) {
	key := ""
	switch rs {
	case ctype.EmailRegister:
		msg = "邮箱已经使用"
		key = "email = ?"
	case ctype.TelRegister:
		msg = "手机号已经使用已经使用"
		key = "tel = ?"
	}
	var user models.UserModel
	err := global.DB.Take(&user, key, val).Error
	if err != nil {
		return false, ""
	}
	return true, msg
}
